/**
 * Created by chenwen on 17-5-16.
 */

var Alipay = require("../lib/Alipay"),
    fs = require("fs"),
    querystring = require("querystring");

let private_key = fs.readFileSync('./alipayKeys/private.pem').toString(),
    public_key = fs.readFileSync('./alipayKeys/public.pem').toString();

var alipay = new Alipay("alipay8888888888888888",private_key, public_key, "2088102147948060","RSA2");


/*var a = private_key.replace(/\r\n/g,"")
    .replace(/\n/g,"");

fs.writeFileSync("./alipayKeys/private.txt", a);*/


//生成账单
var order = alipay.fetchPlaceOrder({
    body : "abc",
    subject : "abc",
    out_trade_no : "123456",
    total_amount :100,
    notify_url :"https://119.23.44.106:3000/"
});
console.log("-------------");
console.log(order);




/*var str = "total_amount=2.00&buyer_id=2088102116773037&body=大乐透2.1&trade_no=2016071921001003030200089909&refund_fee=0.00&notify_time=2016-07-19 14:10:49&subject=大乐透2.1&sign_type=RSA2&charset=utf-8&notify_type=trade_status_sync&out_trade_no=58df6f1914d8b24060501053&gmt_close=2016-07-19 14:10:46&gmt_payment=2016-07-19 14:10:47&trade_status=TRADE_SUCCESS&version=1.0&sign=kPbQIjX+xQc8F0/A6/AocELIjhhZnGbcBN6G4MM/HmfWL4ZiHM6fWl5NQhzXJusaklZ1LFuMo+lHQUELAYeugH8LYFvxnNajOvZhuxNFbN2LhF0l/KL8ANtj8oyPM4NN7Qft2kWJTDJUpQOzCzNnV9hDxh5AaT9FPqRS6ZKxnzM=&gmt_create=2016-07-19 14:10:44&app_id=2015102700040153&seller_id=2088102119685838&notify_id=4a91b7a78a503640467525113fb7d8bg8e"

var obj = querystring.parse(str);
console.log(obj);
var flag = alipay.verify(obj, "abc");

console.log("1111:"+flag);*/

